﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Devart.Data.PostgreSql;
using System.Data;

namespace Sistema_financiero.Entidades
{
    class Sexo
    {
        public int ID { get; set; }
        public string Descripcion { get; set; }

        public static List<Sexo> Obtener_Sexo()
        {
            List<Sexo> lista = new List<Sexo>();
            using (PgSqlConnection conexion = new PgSqlConnection(frm_Menu.conexion))
            {
                conexion.Unicode = true;
                conexion.Open();
                string sql = "SELECT * FROM obtener_sexo";
                PgSqlCommand comando = new PgSqlCommand(sql, conexion);
                PgSqlDataReader reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    lista.Add(Cargar_Sexo(reader));
                }
                conexion.Close();
            }
            return lista;

        }
        private static Sexo Cargar_Sexo(IDataReader reader)
        {
            Sexo item = new Sexo();
            item.ID = Convert.ToInt32(reader[0]);
            item.Descripcion = Convert.ToString(reader[1]);
            return item;
        }
    }
}
